home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / SQL Format252808242001.psc / frmStringFormat.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-08-24  |  23.0 KB  |  684 lines

  1. VERSION 5.00
  2. Begin VB.Form frmStringFormat 
  3.    BackColor       =   &H008080FF&
  4.    Caption         =   "Format SQL v3.0"
  5.    ClientHeight    =   7920
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   8670
  9.    Icon            =   "frmStringFormat.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   7920
  12.    ScaleWidth      =   8670
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.CommandButton CmdClearAll 
  15.       Caption         =   "Clear &All"
  16.       Height          =   390
  17.       Left            =   2550
  18.       TabIndex        =   6
  19.       Top             =   7350
  20.       Width           =   990
  21.    End
  22.    Begin VB.CommandButton cmdCancel 
  23.       Caption         =   "&Cancel"
  24.       Height          =   390
  25.       Left            =   7425
  26.       TabIndex        =   7
  27.       Top             =   7350
  28.       Width           =   990
  29.    End
  30.    Begin VB.CommandButton cmdOK 
  31.       Caption         =   "&OK"
  32.       Height          =   390
  33.       Left            =   6360
  34.       TabIndex        =   5
  35.       Top             =   7350
  36.       Width           =   990
  37.    End
  38.    Begin VB.Frame fOutput 
  39.       BackColor       =   &H008080FF&
  40.       Caption         =   "O&utput"
  41.       Height          =   615
  42.       Left            =   150
  43.       TabIndex        =   14
  44.       Top             =   7200
  45.       Width           =   2265
  46.       Begin VB.OptionButton optFile 
  47.          BackColor       =   &H008080FF&
  48.          Caption         =   "Notepad"
  49.          Height          =   315
  50.          Left            =   1200
  51.          TabIndex        =   16
  52.          Top             =   225
  53.          Width           =   915
  54.       End
  55.       Begin VB.OptionButton optClipBoard 
  56.          BackColor       =   &H008080FF&
  57.          Caption         =   "Clipboard"
  58.          Height          =   315
  59.          Left            =   120
  60.          TabIndex        =   15
  61.          Top             =   225
  62.          Value           =   -1  'True
  63.          Width           =   1065
  64.       End
  65.    End
  66.    Begin VB.CommandButton cmdFormat 
  67.       Caption         =   "&Format String"
  68.       BeginProperty Font 
  69.          Name            =   "Arial"
  70.          Size            =   9
  71.          Charset         =   0
  72.          Weight          =   700
  73.          Underline       =   0   'False
  74.          Italic          =   0   'False
  75.          Strikethrough   =   0   'False
  76.       EndProperty
  77.       Height          =   375
  78.       Left            =   2400
  79.       TabIndex        =   2
  80.       Top             =   4035
  81.       Width           =   3735
  82.    End
  83.    Begin VB.Frame fOptions 
  84.       BackColor       =   &H008080FF&
  85.       Caption         =   "O&ptions"
  86.       BeginProperty Font 
  87.          Name            =   "Arial"
  88.          Size            =   9
  89.          Charset         =   0
  90.          Weight          =   400
  91.          Underline       =   0   'False
  92.          Italic          =   0   'False
  93.          Strikethrough   =   0   'False
  94.       EndProperty
  95.       Height          =   885
  96.       Left            =   2040
  97.       TabIndex        =   8
  98.       Top             =   150
  99.       Width           =   6375
  100.       Begin VB.CheckBox ckContinue 
  101.          BackColor       =   &H008080FF&
  102.          Caption         =   "Line Continuation"
  103.          Height          =   240
  104.          Left            =   360
  105.          TabIndex        =   10
  106.          Top             =   525
  107.          Value           =   1  'Checked
  108.          Width           =   1665
  109.       End
  110.       Begin VB.TextBox txtLineLen 
  111.          Alignment       =   2  'Center
  112.          Height          =   315
  113.          Left            =   4350
  114.          TabIndex        =   13
  115.          Text            =   "75"
  116.          Top             =   450
  117.          Width           =   390
  118.       End
  119.       Begin VB.CheckBox ckQuotes 
  120.          BackColor       =   &H008080FF&
  121.          Caption         =   "Double Quotes to Single Quotes"
  122.          Height          =   255
  123.          Left            =   3300
  124.          TabIndex        =   11
  125.          Top             =   225
  126.          Value           =   1  'Checked
  127.          Width           =   2895
  128.       End
  129.       Begin VB.CheckBox ckVarible 
  130.          BackColor       =   &H008080FF&
  131.          Caption         =   "&Make Variable"
  132.          Height          =   255
  133.          Left            =   360
  134.          TabIndex        =   9
  135.          Top             =   240
  136.          Width           =   1575
  137.       End
  138.       Begin VB.Label lblLineLen 
  139.          BackColor       =   &H008080FF&
  140.          Caption         =   "&Line Length:"
  141.          Height          =   240
  142.          Left            =   3300
  143.          TabIndex        =   12
  144.          Top             =   525
  145.          Width           =   990
  146.       End
  147.    End
  148.    Begin VB.TextBox txtNewString 
  149.       BackColor       =   &H00000000&
  150.       BeginProperty Font 
  151.          Name            =   "Courier New"
  152.          Size            =   9
  153.          Charset         =   0
  154.          Weight          =   400
  155.          Underline       =   0   'False
  156.          Italic          =   0   'False
  157.          Strikethrough   =   0   'False
  158.       EndProperty
  159.       ForeColor       =   &H0000FF00&
  160.       Height          =   2655
  161.       Left            =   120
  162.       MultiLine       =   -1  'True
  163.       ScrollBars      =   3  'Both
  164.       TabIndex        =   4
  165.       Top             =   4440
  166.       Width           =   8295
  167.    End
  168.    Begin VB.TextBox txtOldString 
  169.       BackColor       =   &H00000000&
  170.       BeginProperty Font 
  171.          Name            =   "Courier New"
  172.          Size            =   9
  173.          Charset         =   0
  174.          Weight          =   400
  175.          Underline       =   0   'False
  176.          Italic          =   0   'False
  177.          Strikethrough   =   0   'False
  178.       EndProperty
  179.       ForeColor       =   &H0000FF00&
  180.       Height          =   2655
  181.       Left            =   120
  182.       MultiLine       =   -1  'True
  183.       ScrollBars      =   3  'Both
  184.       TabIndex        =   1
  185.       Top             =   1320
  186.       Width           =   8295
  187.    End
  188.    Begin VB.TextBox txtVar 
  189.       BeginProperty Font 
  190.          Name            =   "Arial"
  191.          Size            =   9
  192.          Charset         =   0
  193.          Weight          =   400
  194.          Underline       =   0   'False
  195.          Italic          =   0   'False
  196.          Strikethrough   =   0   'False
  197.       EndProperty
  198.       Height          =   285
  199.       Left            =   120
  200.       TabIndex        =   18
  201.       Text            =   "gstrSQL"
  202.       Top             =   480
  203.       Width           =   1815
  204.    End
  205.    Begin VB.Label Label4 
  206.       BackStyle       =   0  'Transparent
  207.       Caption         =   "Modified by: Gregor Brown"
  208.       Height          =   240
  209.       Left            =   3600
  210.       TabIndex        =   21
  211.       Top             =   7440
  212.       Width           =   2475
  213.    End
  214.    Begin VB.Label Label2 
  215.       BackStyle       =   0  'Transparent
  216.       Caption         =   "Written By: Chris Shell"
  217.       Height          =   240
  218.       Left            =   3600
  219.       TabIndex        =   20
  220.       Top             =   7200
  221.       Width           =   2475
  222.    End
  223.    Begin VB.Label Label1 
  224.       Caption         =   "Label1"
  225.       Height          =   315
  226.       Left            =   3300
  227.       TabIndex        =   19
  228.       Top             =   375
  229.       Width           =   1665
  230.    End
  231.    Begin VB.Label lblNewString 
  232.       BackStyle       =   0  'Transparent
  233.       Caption         =   "&New String:"
  234.       BeginProperty Font 
  235.          Name            =   "Arial"
  236.          Size            =   9
  237.          Charset         =   0
  238.          Weight          =   400
  239.          Underline       =   0   'False
  240.          Italic          =   0   'False
  241.          Strikethrough   =   0   'False
  242.       EndProperty
  243.       Height          =   255
  244.       Left            =   120
  245.       TabIndex        =   3
  246.       Top             =   4080
  247.       Width           =   1335
  248.    End
  249.    Begin VB.Label lOldText 
  250.       BackStyle       =   0  'Transparent
  251.       Caption         =   "&String to be Formatted:"
  252.       BeginProperty Font 
  253.          Name            =   "Arial"
  254.          Size            =   9
  255.          Charset         =   0
  256.          Weight          =   400
  257.          Underline       =   0   'False
  258.          Italic          =   0   'False
  259.          Strikethrough   =   0   'False
  260.       EndProperty
  261.       Height          =   255
  262.       Left            =   120
  263.       TabIndex        =   0
  264.       Top             =   960
  265.       Width           =   1950
  266.    End
  267.    Begin VB.Label lVar 
  268.       BackStyle       =   0  'Transparent
  269.       Caption         =   "&Varible Name:"
  270.       BeginProperty Font 
  271.          Name            =   "Arial"
  272.          Size            =   9
  273.          Charset         =   0
  274.          Weight          =   400
  275.          Underline       =   0   'False
  276.          Italic          =   0   'False
  277.          Strikethrough   =   0   'False
  278.       EndProperty
  279.       Height          =   255
  280.       Left            =   120
  281.       TabIndex        =   17
  282.       Top             =   195
  283.       Width           =   1215
  284.    End
  285. Attribute VB_Name = "frmStringFormat"
  286. Attribute VB_GlobalNameSpace = False
  287. Attribute VB_Creatable = False
  288. Attribute VB_PredeclaredId = True
  289. Attribute VB_Exposed = False
  290. Option Explicit
  291. ' *************************************************************
  292. '  Format String
  293. '  Chris Shell
  294. '  http://www.cshellvb.com
  295. ' *************************************************************
  296. '  Author grants royalty-free rights to use this code within
  297. '  compiled applications. Selling or otherwise distributing
  298. '  this source code is not allowed without author's express
  299. '  permission.
  300. ' *************************************************************
  301. Const DIM_STR1                                    As String = "Dim "
  302. Const DIM_STR2                                    As String = " as String"
  303. Const CONT_STR                                    As String = " & _"
  304. Const CONNECT_STR                                 As String = " & "
  305. Dim maSQLVar()                                    As Integer
  306. '**************************************
  307. 'Windows API/Global Declarations for :
  308. 'Create links from labels!
  309. '**************************************
  310. Public Enum OpType
  311.     Startup = 1
  312.     Click = 2
  313.     FormMove = 3
  314.     LinkMove = 4
  315. End Enum
  316. Dim Clicked As Boolean
  317. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  318. Function CleanString(szOriginal)
  319.     If szOriginal = "" Then
  320.         CleanString = "NULL"
  321.     Else
  322.         CleanString = Substitute(szOriginal, Chr(34), "'")
  323.         'CleanString = Substitute(szOriginal, "'", "''")
  324.         'CleanString = Substitute(CleanString, "
  325.     End If
  326. End Function
  327. Private Sub cmdCancel_Click()
  328.     Unload Me
  329. End Sub
  330. Private Sub CmdClearAll_Click()
  331.     If MsgBox("Clear all text boxes?", vbYesNo + vbQuestion, "Clear") = vbYes Then
  332.         txtNewString.Text = ""
  333.         txtOldString.Text = ""
  334.         
  335.     End If
  336.     Me.Refresh
  337. End Sub
  338. Private Sub cmdFormat_Click()
  339. Dim bContinue As Boolean, strVariableName As String
  340. Dim bQuote As Boolean, intMaxLineLength As Integer, bSQLSmart As Boolean
  341.     bContinue = False
  342.     strVariableName = ""
  343.     bQuote = False
  344.     bSQLSmart = False
  345.     If Len(txtOldString.Text) = 0 Then
  346.         MsgBox "No String entered!", vbExclamation
  347.         Exit Sub
  348.     End If
  349. '    If ckSQLSmart.Value = vbChecked Then
  350. '       bSQLSmart = True
  351. '    End If
  352.     If ckContinue.Value = vbChecked Then
  353.        bContinue = True
  354.     End If
  355.     If ckQuotes.Value = vbChecked Then
  356.         bQuote = True
  357.     End If
  358.     'set up the variable.
  359.     strVariableName = txtVar.Text
  360.     If IsNumeric(txtLineLen.Text) Then
  361.       intMaxLineLength = CInt(txtLineLen.Text)
  362.     Else
  363.       'Default.
  364.       intMaxLineLength = 50
  365.     End If
  366.         
  367.     txtNewString.Text = FormatSQL(txtOldString.Text, bContinue, intMaxLineLength, strVariableName, bQuote)
  368.     'Auto-tab
  369.     SendKeys "{TAB}"
  370. End Sub
  371. Function Substitute(szBuff, szOldString, szNewString)
  372.     Dim iStart
  373.     Dim iEnd
  374.     ''' Find first substring
  375.     iStart = InStr(1, szBuff, szOldString)
  376.     ''' Loop through finding substrings
  377.     Do While iStart <> 0
  378.         ''' Find end of string
  379.         iEnd = iStart + Len(szOldString)
  380.         ''' Concatenate new string
  381.         szBuff = Left(szBuff, iStart - 1) & szNewString & Right(szBuff, Len(szBuff) - iEnd + 1)
  382.         ''' Advance past new string
  383.         iStart = iStart + Len(szNewString)
  384.         ''' Find next occurrence
  385.         iStart = InStr(iStart, szBuff, szOldString)
  386.     Loop
  387.     Substitute = szBuff
  388. End Function
  389. Function RemoveChar(sText As String, sChar As String) As String
  390.     Dim iPos As Integer, iStart As Integer
  391.     Dim sTemp As String
  392.     iStart = 1
  393.     Do
  394.         iPos = InStr(iStart, sText, sChar)
  395.         If iPos <> 0 Then
  396.             sTemp = sTemp & Mid(sText, iStart, (iPos - iStart))
  397.             iStart = iPos + 1
  398.         End If
  399.     Loop Until iPos = 0
  400.     sTemp = sTemp & Mid(sText, iStart)
  401.     RemoveChar = sTemp
  402. End Function
  403. Sub SQLVarPos(ByVal sSQL As String)
  404. Dim intPosition                                   As Integer
  405. Dim intLength                                     As Integer
  406. Dim intClauseI                                    As Integer
  407. Dim intI                                          As Integer
  408. Dim intStartPos                                   As Integer
  409. Dim intArrayArgument                              As Integer
  410. Dim intTemp                                       As Integer
  411. Dim intWordCount                                  As Integer
  412. Dim strClause                                     As String
  413. Dim strWord                                       As String
  414. On Error GoTo ehHandle
  415. intWordCount = CountWords(sSQL)
  416. 'initialize
  417. intArrayArgument = 0
  418. 'Redim.
  419. ReDim maSQLVar(0 To intWordCount - 1, 0 To 1)
  420. 'Add files to arrary.
  421. ReadFileIntoArray App.Path & "\SqlClauses.txt"
  422. 'Go thru all words
  423. For intI = 1 To intWordCount
  424.   intPosition = 0
  425.   'Get word.
  426.   strWord = GetWord(sSQL, intI, intStartPos)
  427.   'Now test to see if word is a key word.
  428.   'Try reading file.
  429.   For intClauseI = 0 To UBound(gastrClause)                'Add acronyms to list.
  430.     strClause = gastrClause(intClauseI)
  431.     Debug.Print strClause
  432.     'Find out the number of words in the clause.
  433.     If CountWords(strClause) = 1 Then
  434.       'Check for a match.
  435.       If StrComp(strWord, strClause, vbTextCompare) = 0 Then
  436.         intPosition = intStartPos
  437.         intLength = Len(strClause)
  438.       End If
  439.     Else
  440.       'Compare first word.
  441.       If StrComp(strWord, GetWord(strClause, 1, intTemp), vbTextCompare) = 0 Then
  442.         intPosition = intStartPos
  443.         'Get next word
  444.         intI = intI + 1
  445.         strWord = strWord & " " & GetWord(sSQL, intI, intStartPos)
  446.         If StrComp(strWord, strClause, vbTextCompare) = 0 Then
  447.           intLength = Len(strClause)
  448.         Else
  449.           'Set position to zero...No match.
  450.           intPosition = 0
  451.         End If
  452.       End If
  453.     End If
  454.     'Check for match to exit for and write off values.
  455.     If intPosition > 0 Then
  456.       'Write values to array
  457.       maSQLVar(intArrayArgument, 0) = intPosition
  458.       maSQLVar(intArrayArgument, 1) = intLength
  459.       intArrayArgument = intArrayArgument + 1
  460.       Exit For
  461.     End If
  462.   Next intClauseI
  463. Next intI
  464. SUB_EXIT:
  465.     Exit Sub
  466. ehHandle:
  467.     MsgBox "SQLVarPos: " & Err.Number & " - " & Err.Description
  468.     Resume Next
  469. End Sub
  470. Private Sub cmdOK_Click()
  471. Dim hFile As Integer
  472. Dim sFilename As String
  473. Dim iFileName As Integer
  474.     If optClipBoard.Value = True Then
  475.         ClipboardCopy txtNewString.Text
  476.         MsgBox "Your code on the Clipboard, Enjoy!", vbExclamation
  477.         
  478.     Else
  479.         
  480.         iFileName = Int((10000 - 100 + 1) * Rnd + 100)
  481.         'obtain the next free file handle from the system
  482.         hFile = FreeFile
  483.         sFilename = App.Path & "\tmp" & iFileName & ".txt"
  484.          
  485.         'open and save the textbox to a file
  486.         Open sFilename For Output As #hFile
  487.             Print #hFile, (txtNewString.Text)
  488.         Close #hFile
  489.         If Err.Number <> 0 Then
  490.             MsgBox "Problem creating temporary file! The disk may be full or read only.", vbExclamation
  491.             Err.Clear
  492.             Exit Sub
  493.         End If
  494.         
  495.         Call Shell("Notepad " & sFilename, vbNormalFocus)
  496.                 
  497.         Kill sFilename
  498.         
  499.         MsgBox "Your code is in Notepad, Enjoy!", vbExclamation
  500.         
  501.     End If
  502.     Unload Me
  503. End Sub
  504. Public Sub ClipboardCopy(Text As String)
  505. 'Copies text to the clipboard
  506. On Error GoTo error
  507.     Clipboard.Clear
  508.     Clipboard.SetText Text$
  509. Exit Sub
  510. error:  MsgBox Err.Description, vbExclamation, "Error"
  511. End Sub
  512. Private Sub Form_Resize()
  513.     ResizeForm Me
  514. End Sub
  515. Public Function FormatSQL(strSql As String, booLineContinue As Boolean, intMaxLineLength As Integer, strVariableName As String, booFixQuotes As Boolean) As String
  516. Dim booEnd                                        As Boolean
  517. Dim booKeyWordBreak                               As Boolean
  518. Dim booKeyWordNoTab                               As Boolean
  519. Dim intArrayArgument                              As Integer
  520. Dim intI                                          As Integer
  521. Dim intLineCount                                  As Integer
  522. Dim intLineLength                                 As Integer
  523. Dim intStartPos                                   As Integer
  524. Dim intTotalLineLength                            As Integer
  525. Dim intWordCount                                  As Integer
  526. Dim intWordI                                      As Integer
  527. Dim strSqlPart                                    As String
  528. Dim strWord                                       As String
  529. '********************************************
  530. 'This class was written by:
  531. '   Karl E. Peterson
  532. '   http://www.mvps.org/vb/
  533. 'See the class for more detail. Thank you to
  534. 'him for this code, I got it via VBPJ Article
  535. 'on string building in ASP.
  536. '********************************************
  537. Dim cSBld As New CStringBuilder
  538. On Error GoTo ehHandle
  539.         
  540. '********************************************
  541. 'Clean up String before we begin...
  542. '********************************************
  543.   'Remove Tab Characters
  544.   strSql = RemoveChar(strSql, CStr(vbTab))
  545.   'Remove Carriage Returns
  546.   strSql = Replace(strSql, CStr(vbCr), CStr(Chr(32)))
  547.   'Remove Line Feeds
  548.   strSql = RemoveChar(strSql, CStr(vbLf))
  549.   'Remove extra Spaces
  550.   strSql = Trim(strSql)
  551.         
  552. '********************************************
  553. 'Ready to Rock...
  554. '********************************************
  555.   'Replace any quotes with single quotes if desired
  556.   If booFixQuotes = True Then
  557.       strSql = CleanString(strSql)
  558.   End If
  559.   'If a variable is given te use it...
  560.   If Len(strVariableName) > 0 Then
  561.     If ckVarible.Value = vbChecked Then
  562.       cSBld.Append DIM_STR1 & strVariableName & DIM_STR2 & vbCrLf & vbCrLf
  563.     End If
  564.   End If
  565.   'Set Key SQL Positions in Array
  566.   Call SQLVarPos(strSql)
  567.   'Initialize.
  568.   booEnd = False
  569.   booKeyWordBreak = False
  570.   booKeyWordNoTab = False
  571.   intArrayArgument = 1
  572.   'Start with append of variable name.
  573.   cSBld.Append strVariableName & " = "
  574.       
  575.   'Store original length
  576.   intTotalLineLength = Len(strSql)
  577.   'Check for a short SQL line.
  578.   If intTotalLineLength <= intMaxLineLength Then
  579.     cSBld.Append ContinueString(strSql, True)
  580.   Else
  581.     'Get word count.
  582.     intWordCount = CountWords(strSql)
  583.     'Go thru all words.
  584.     For intWordI = 1 To intWordCount
  585.       'Get word.
  586.       strWord = GetWord(strSql, intWordI, intStartPos)
  587.       
  588.       'Build.
  589.       strSqlPart = strSqlPart & strWord & " "
  590.           
  591.       'Look for key SQL Clause at the start position of the next word.
  592.       If maSQLVar(intArrayArgument, 0) = intStartPos + Len(strWord) + 1 Then
  593.         'Set the array argument.
  594.         intArrayArgument = intArrayArgument + 1
  595.         booKeyWordBreak = True
  596.       End If
  597.       
  598.       'Check length.
  599.       intLineLength = Len(strSqlPart)
  600.       
  601.       'Check for end of SQL.
  602.       If intWordI = intWordCount Then
  603.         booEnd = True
  604.         strSqlPart = Left(strSqlPart, Len(strSqlPart) - 1)
  605.       End If
  606.         
  607.       'Append if needed.
  608.       If intLineLength >= intMaxLineLength Or booEnd Or booKeyWordBreak Then
  609.         intLineCount = intLineCount + 1
  610.         
  611.         'Check if the user wants line continuation.
  612.         If booLineContinue Then
  613.           
  614.           'Add in general tab for every line but the first.
  615.           If intLineCount > 1 Then cSBld.Append "  "
  616.             
  617.           'Check for no tab.
  618.           If booKeyWordNoTab Then
  619.             'Set the boolean back to its origional value.
  620.             booKeyWordNoTab = False
  621.           Else
  622.             'Add in extra tab for none keywords (if not the first line).
  623.             If intLineCount > 1 Then cSBld.Append "  "
  624.           End If
  625.           'Set the boolean for next loop.
  626.           If booKeyWordBreak Then booKeyWordNoTab = True
  627.           
  628.           'Add the string.
  629.           cSBld.Append ContinueString(strSqlPart, booEnd)
  630.           Debug.Print strSqlPart
  631.         Else
  632.           
  633.           cSBld.Append AppendString(strVariableName, strSqlPart, booEnd)
  634.         End If
  635.         'Append line feed.
  636.         cSBld.Append vbCrLf
  637.       
  638.         'Reset temp string.
  639.         strSqlPart = ""
  640.          
  641.         'Reset value.
  642.         booKeyWordBreak = False
  643.       End If
  644.       
  645.     Next intWordI
  646.   End If
  647.   'Pass the String Back...
  648.   FormatSQL = cSBld.ToString
  649.   Set cSBld = Nothing
  650. ExitFunc:
  651.     Exit Function
  652. ehHandle:
  653.     MsgBox "ERROR: " & Err.Number & " - " & Err.Description
  654.     Resume Next
  655. End Function
  656. Private Function ContinueString(sLine As String, bEnd As Boolean) As String
  657.     If bEnd Then
  658.         ContinueString = Chr(34) & sLine & Chr(34)
  659.     Else
  660.         ContinueString = Chr(34) & sLine & Chr(34) & CONT_STR
  661.     End If
  662. End Function
  663. Private Function AppendString(sVar As String, sLine As String, bEnd As Boolean) As String
  664.     If bEnd Then
  665.          AppendString = sVar & " = " & sVar & CONNECT_STR & _
  666.                                 Chr(34) & sLine & Chr(34)
  667.     Else
  668.          AppendString = sVar & " = " & sVar & CONNECT_STR & _
  669.                                 Chr(34) & sLine & Chr(34)
  670.     End If
  671. End Function
  672. Private Sub txtNewString_GotFocus()
  673. 'To highlight text on enter.
  674. txtNewString.SelStart = 0
  675. 'A very high value always works.
  676. txtNewString.SelLength = 19999
  677. End Sub
  678. Private Sub txtOldString_GotFocus()
  679. 'To highlight text on enter.
  680. txtOldString.SelStart = 0
  681. 'A very high value always works.
  682. txtOldString.SelLength = 19999
  683. End Sub
  684.